from dataclasses import dataclass
from pathlib import Path

import rich


@dataclass
class AstChecker:
    test_file: Path
    astchecker: bool = True


class Checker:
    def __init__(self, ast: Path):
        self.ast = ast.expanduser().resolve()

    def resolve_test(self, ets_test: Path):
        test = ets_test.expanduser().resolve()
        for path in test.parents:
            rich.print(path, self.ast)
            if path == self.ast:
                return AstChecker(test_file=test.relative_to(self.ast.parent))
        raise RuntimeError('Checker not found for', ets_test)
